# encoding:utf-8
# user: ares at 18-9-18

from .sql import Sql
from ershoufang.items import ErshoufangItem

class ErshoufangPipeline(object):

    def process_item(self,item,spider):

        if isinstance(item,ErshoufangItem):
            title=item['title']
            laiyuan=item['laiyuan']
            ret=Sql.select_title(title,laiyuan)
            if ret[0]==1:
                print('数据已经存在')
                pass
            else:
                Sql.insert_ershoufang(item)
                print('开始工作')